// pages/auth/index.js
import { login } from '../../lib/asyncWx/asyncWx.js';
const regeneratorRuntime = require('../../lib/runtime/runtime.js');
import { request } from '../../request/index.js';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    defaultToken:
      'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOjIzLCJpYXQiOjE1NjQ3MzAwNzksImV4cCI6MTAwMTU2NDczMDA3OH0.YPt-XeLnjV-_1ITaXGY2FhxmCe4NvXuRnRB8OMCfnPo',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },
  handleGetUserInfo(e) {
    console.log(e);
    let { defaultToken } = this.data;
    // 获取用户信息
    const { encrypteData, rawData, iv, signature } = e.detail;
    // 获取code
    // const { code } = await login();
    // console.log('code', code);
    // const loginParams = { encrypteData, rawData, iv, signature, code };
    // 获取用户的token //token接口因没有企业微信appId,故无法生效;
    // let res = await request({ url: '/users/wxlogin', data: loginParams, methods: 'POST' });
    // res = res === null ? defaultToken : res;
    let token = defaultToken;
    // 存缓存中
    wx.setStorageSync('token', token);
    // 返回支付页面
    wx.navigateBack({
      delta: 1, // 回退前 delta(默认为1) 页面
    });
  }
})